const throttle = <T extends (...args: Object[]) => void>(
  fun: Function,
  time: number = 100
): ((...args: Parameters<T>) => void) => {
  let lastTime = 0;
  return function (...args: Parameters<T>) {
    const date = +new Date();
    if (date - lastTime > time) {
      lastTime = date;
      fun.apply(fun, args);
    }
  };
};

const fun1 = throttle(() => {
  console.log(1);
}, 1000);
setInterval(() => {
  fun1(); // 每秒调用一次已节流的函数
}, 1000);
